<?php 
    namespace Home\Model;
    use Think\Model;
    class UserModel extends Model{
        //自动验证
        protected $patchValidate = true;
        protected $_validate = array(
          array('username','/^\w{6,12}$/','用户名必须是6-12位的shuzi、字母、下划线',0,'regex',1),
          array('email','email','不符合邮箱格式'),
          array('username','','用户名已经存在！',0,'unique',1),
          array('nickname','require','昵称不能为空',0,'regex',1),
          array('passwd','/^\w{6,12}$/','密码必须是6-12位的shuzi、字母、下划线',0,'regex',1),
          array('repasswd','passwd','确认密码不正确',0,'confirm',1), // 验证确认密码是否和密码一致
          array('repasswd','require','确认密码不能为空',0,'regex',1),
        );
        public function vLogin($username,$passwd)
        {
            if($username == '' or $passwd == '')
            {
                return false;
            }
            $model = M('User');
            $result = $model->where("username='{$username}' AND passwd='{$passwd}'")->find();
            if($result == null)
            {
                return false;
            }else
            {
                return $result;
            }
        }
    }